<template>
  <div>
    <van-nav-bar title="我的" />
    <div class="top-content">
      <div class="user-info">
        <div class="avatar-content">
          <van-image
            round
            width="50px"
            height="50px"
            src="https://img01.yzcdn.cn/vant/cat.jpeg"
          />
        </div>
        <div class="right-content">
          <div class="name-content">
            {{ getUserInfo().nickName || "夏琳恒" }}
            <span class="post">心内科·主任医师</span>
          </div>
          <div class="info-content">浙江省人民医院（天府院区）</div>
        </div>
      </div>
    </div>
    <div class="login_btn">
      <van-button block @click="logout" style="width: 90%">
        退出登录
      </van-button>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
export default {
  methods: {
    getUserInfo() {
      const info = Vue.ls.get("userInfo") || {};
      const userInfo = info.user || {};
      return userInfo;
    },
    logout() {
      this.$dialog
        .confirm({
          title: "退出登录提示",
          message: "您确定退出登录吗？",
        })
        .then(() => {
          Vue.ls.clear();
          this.$router.replace("/login");
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.top-content {
  height: 300px;
  background-image: url("~@/assets/login/login-bg.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  padding: 24px;

  .user-info {
    display: flex;
    align-items: center;
    background-color: #fff;
    border-radius: 8px;
    padding: 12px;

    .right-content {
      margin-left: 24px;
      font-size: 16px;

      .name-content {
        font-weight: 600;

        .post {
          margin-left: 12px;
          color: #333;
          font-size: 14px;
          font-weight: 500;
        }
      }

      .info-content {
        margin-top: 12px;
        font-size: 14px;
      }
    }
  }
}

.login_btn {
  position: absolute;
  bottom: 120px;
  width: 100%;
  display: flex;
  justify-content: center;
}
</style>
